<!--物流-->
<template>
	<view class="logistics_container auto">
		<view class="logistics_top border">
			<view class="display align-items ">
				<view class="logistics_top_left">配送方式</view>
				<view class="logistics_top_right">{{deliveryName}}</view>
			</view>
			<view class="display align-items" style="margin-top: 8rpx">
				<view class="logistics_top_left">快递单号</view>
				<view class="logistics_top_right">{{waybillId}}</view>
				<image @tap.stop="copy(waybillId)" class="logistics_top_icon" src="../../../static/icon/copy.png"></image>
			</view>
		</view>
		<view class="logistics_info">
			<view class="logistics_info_details display " v-for="(item,i) in deliveryInfo" :key="i">
				<view class="logistics_info_details_ls ">
					<view class="icon_yuan"></view>
					<view class="icon_icon display justify-content">
						<view  v-if="i!==deliveryInfo.length-1"></view>
					</view>
				</view>
				<view class="logistics_info_details_rg">
					<view class="logistics_info_details_rg_info">{{item.action_msg}}</view>
					<view class="logistics_info_details_rg_time">{{item.action_time}}</view>
				</view>
			</view>
		</view>
		<view class="no_thing" v-if="noOrder">
			<view class="no_thing_text">暂无物流信息</view>
		</view>
		<is-login v-on:childClick='listenToClose' v-on:childClickAgain='listenToCloseAgain' v-if="isLogin==0"></is-login>
	</view>
</template>

<script>
	import checktime from '../../../util/formTime.js'
	import isLogin from '../../../components/isLogin.vue'
	export default {
		data() {
			return {
				isLogin: 1,
				id: '',
				deliveryName: '',
				waybillId: '',
				deliveryInfo: [],
				noOrder:false
			}
		},
		components: {
			isLogin,
		},
		onLoad(option) {
			if (!uni.getStorageSync('openid')) {
				this.isLogin = 0
			} else {
				var id = option.id
				this.id = id
				this.getDelivery()
			}
		},
		onPullDownRefresh() {
			this.noOrder = false
			uni.showToast({
				icon: 'loading',
				title: '加载中',
			});
			setTimeout(() => {
				this.getDelivery(() => {
					uni.hideLoading()
					uni.stopPullDownRefresh()
				})
			}, 1000)
		},
		methods: {
			// 物流信息
			getDelivery(callback) {
				let that = this;
				var data = {
					openid: uni.getStorageSync('openid'),
					id: that.id
				}
				that.$myRequest.post(that.$api.order.getDeliveryPath, data).then(res => {
					callback && callback()
					if (res.code == '200') {
						if (res.data.data.length == 0) {
							// noOrder
							this.noOrder = true
						} else {
							this.noOrder = false
							for (let i = 0; i < res.data.data.length; i++) {
								res.data.data[i].action_time =checktime.changeTime(res.data.data[i].action_time)
							}
							this.deliveryInfo = res.data.data
						}

						this.deliveryName = res.data.delivery_name
						this.waybillId = res.data.waybill_id
					} else {
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
					}
				})
			},
			copy: function(value) {
				uni.setClipboardData({
					data: value, // 要复制的文字
					success: function(res) {
						uni.getClipboardData({
							success: function(res) {
								uni.showToast({
									title: '复制成功'
								});
							}
						});
					}
				});
			},
			listenToClose(msg) {
				this.isLogin = msg
			},
			listenToCloseAgain() {
				this.getDelivery()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.logistics_container {
		width: 690rpx;

		.logistics_top {
			padding: 26rpx 20rpx;
			margin-top: 10rpx;
			border-radius: 10rpx;

			.logistics_top_left {
				color: #666666;
				font-size: 26rpx;
			}

			.logistics_top_right {
				font-size: 26rpx;
				color: #333;
				margin-left: 40rpx;
			}

			.logistics_top_icon {
				width: 17rpx;
				height: 17rpx;
				margin-left: 18rpx;
			}
		}

		.logistics_info {
			margin-top: 45rpx;

			.logistics_info_details {
				padding: 0 20rpx;

				.logistics_info_details_ls {

					.icon_yuan {
						width: 12rpx;
						height: 12rpx;
						background-color: #D8D8D8;
						border-radius: 8rpx;
					}

					.icon_icon {
						width: 12rpx;
						view {
							height: 50rpx;
							width: 1px;
							height: 120rpx;
							background: #EAEAEA;
						}
					}
				}

				.logistics_info_details_rg {
					margin-left: 30rpx;
					width: 550rpx;
					margin-top: -10rpx;
					.logistics_info_details_rg_info {
						font-size: 26rpx;
						color: #999999;
					}

					.logistics_info_details_rg_time {
						color: #999999;
						font-size: 22rpx;
						margin-top: 8rpx;
					}
				}
			}
		}
	}
</style>
